package com.ecjtu.stadiumre_servations.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ecjtu.stadiumre_servations.entity.domain.GroupActivity;
import com.ecjtu.stadiumre_servations.entity.domain.GroupMember;
import com.ecjtu.stadiumre_servations.entity.dto.GroupActivityDTO;
import com.ecjtu.stadiumre_servations.entity.dto.GroupActivityQueryDTO;
import com.ecjtu.stadiumre_servations.mapper.GroupMemberMapper;
import com.ecjtu.stadiumre_servations.response.Result;
import com.ecjtu.stadiumre_servations.service.GroupActivityService;
import com.ecjtu.stadiumre_servations.service.GroupMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/groupMember")
public class GroupMemberController {
    @Autowired
    private GroupMemberService groupMemberService;
    @GetMapping("/selectByRecordId")
    public    Result selectByRecordId(String groupRecordId){
        return groupMemberService.selectByRecordId(groupRecordId);
    }
    @GetMapping("/selectByUserId/{userId}")
    public Result selectByUserId(@PathVariable String userId){
        return groupMemberService.selectByUserId(userId);
    }
    @PostMapping("/isUserInGroup")
    public Result isUserInGroup(@RequestParam String userId, @RequestParam String groupRecordId){
        return groupMemberService.isUserInGroup(userId,groupRecordId);
    }
    @GetMapping("/selectByUserAndTimeRange")
    public Result selectByUserAndTimeRange(@RequestParam String userId, @RequestParam String startTime, @RequestParam String endTime){
        return groupMemberService.selectByUserAndTimeRange(userId, startTime,endTime);
    }
    @GetMapping("/selectPageByRecordId/{recordId}")
    public Result selectPageByRecordId(Page<GroupMember> page, @PathVariable String recordId){
        return groupMemberService.selectPageByRecordId(page,recordId);
    }
    @GetMapping("/selectLeaderByRecordId/{recordId}")
    public Result selectLeaderByRecordId(@PathVariable String recordId){
        return groupMemberService.selectLeaderByRecordId(recordId);
    }
    @GetMapping("/selectLeaderGroupsByUserId/{userId}")
    public Result selectLeaderGroupsByUserId(@PathVariable String userId){
        return groupMemberService.selectLeaderGroupsByUserId(userId);
    }
    @DeleteMapping("/deleteByRecordId/{groupRecordId}")
    public Result deleteByRecordId(@PathVariable String groupRecordId){
        return groupMemberService.deleteByRecordId(groupRecordId);
    }
    @DeleteMapping("/exitTheGroup")
    public Result exitTheGroup(String groupRecordId, @RequestParam  String userId){
        return groupMemberService.exitTheGroup(groupRecordId,userId);
    }

}
